package com.ln.cmsln.controller;


import com.alibaba.fastjson.JSON;
import com.ln.cmsln.pojo.entity.Photo;
import com.ln.cmsln.service.PhotoService;
import com.ln.cmsln.utils.LayuiPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wuwenzhe
 * @since 2022-03-31
 */
@Api(tags = "头部区大图")
@CrossOrigin
@RestController
@RequestMapping("/api/photo")
public class PhotoController {

   @Resource
    private PhotoService photoService;


   @ApiOperation("列表信息")
   @GetMapping("/all")
    public  Object  getAll(){
       List<Photo> list = photoService.list(null);
       HashMap<String, Object> map = new HashMap<>();
       map.put("code",0);
       map.put("count",0);
       map.put("data",list);
      return  map;
   }
   @ApiOperation("删除列表信息")
   @PostMapping("remove")
   public  boolean  delById( Long pid){

      //根据id删除
      boolean b = photoService.removeById(pid);
      return b;
   }
   @ApiOperation("增加列表信息")
   @PostMapping("save")
   public  boolean add(@ApiParam(value = "新增图片信息", required = true)Photo photo
                       ){
      return  photoService.save(photo);
   }


}

